package model;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

public class EvaluationResult {

    private String projectCode;
    // 焊接方法
    private TranslateResult weldMethod;
    // 焊接类型
    private TranslateResult weldMethodType;
    // 试件形式
    private TranslateResult specimen;
    // 焊缝形式
    private TranslateResult gap;
    // 填充材料
    private TranslateResult material;
    // 药皮
    private TranslateResult coating;
    // 焊缝金属厚度
    private TranslateResult thickness;
    // 管试件外径
    private TranslateResult diameter;
    // 外管壁厚
    private TranslateResult outThickness;
    // 焊接位置
    private TranslateResult position;
    // 焊接要素
    private List<TranslateResult> element;
    // 厚度及直径
    private TranslateResult thicknessAndDiameter;
    // （自动焊）焊机型号
    private TranslateResult machineType;

    public EvaluationResult() {
        this.element = new ArrayList<TranslateResult>();
    }

    public EvaluationResult(String projectCode) {
        this.projectCode = projectCode;
        this.element = new ArrayList<TranslateResult>();
    }

    public void addElement(TranslateResult translateResult) {
        this.element.add(translateResult);
    }

    public String getProjectCode() {
        return projectCode;
    }

    public void setProjectCode(String projectCode) {
        this.projectCode = projectCode;
    }

    public TranslateResult getWeldMethod() {
        return weldMethod;
    }

    public void setWeldMethod(TranslateResult weldMethod) {
        this.weldMethod = weldMethod;
    }

    public TranslateResult getSpecimen() {
        return specimen;
    }

    public void setSpecimen(TranslateResult specimen) {
        this.specimen = specimen;
    }

    public TranslateResult getGap() {
        return gap;
    }

    public void setGap(TranslateResult gap) {
        this.gap = gap;
    }

    public TranslateResult getMaterial() {
        return material;
    }

    public void setMaterial(TranslateResult material) {
        this.material = material;
    }

    public TranslateResult getCoating() {
        return coating;
    }

    public void setCoating(TranslateResult coating) {
        this.coating = coating;
    }

    public TranslateResult getPosition() {
        return position;
    }

    public void setPosition(TranslateResult position) {
        this.position = position;
    }

    public TranslateResult getThicknessAndDiameter() {
        return thicknessAndDiameter;
    }

    public void setThicknessAndDiameter(TranslateResult thicknessAndDiameter) {
        this.thicknessAndDiameter = thicknessAndDiameter;
    }

    public List<TranslateResult> getElement() {
        return element;
    }

    public void setElement(List<TranslateResult> element) {
        this.element = element;
    }

    public TranslateResult getThickness() {
        return thickness;
    }

    public void setThickness(TranslateResult thickness) {
        this.thickness = thickness;
    }

    public TranslateResult getDiameter() {
        return diameter;
    }

    public void setDiameter(TranslateResult diameter) {
        this.diameter = diameter;
    }

    public TranslateResult getOutThickness() {
        return outThickness;
    }

    public void setOutThickness(TranslateResult outThickness) {
        this.outThickness = outThickness;
    }

    public TranslateResult getWeldMethodType() {
        return weldMethodType;
    }

    public void setWeldMethodType(TranslateResult weldMethodType) {
        this.weldMethodType = weldMethodType;
    }

    public TranslateResult getMachineType() {
        return machineType;
    }

    public void setMachineType(TranslateResult machineType) {
        this.machineType = machineType;
    }

    // 反射打印非空字段
    @Override
    public String toString() {
        Class c = this.getClass();
        StringBuilder stringBuilder = new StringBuilder();
        Field[] fields = c.getDeclaredFields();
        System.out.println("________________________________________________________________________________________");
        try {
            for (Field field : fields) {
                if (null != field.get(this)) {
                    if (field.getName()=="element"){
                        for (TranslateResult translateResult:element){
                            String elementString = translateResult.toString()+"\n";
                            stringBuilder.append(elementString);
                        }
                    }else {
                        String tmp = field.get(this) + " \n";
                        stringBuilder.append(tmp);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println(stringBuilder.toString());;
        System.out.println("________________________________________________________________________________________");
        return "";
    }
}
